const componentBehavior = require('../../../js/common/ComponentBehavior')

Component({
  properties: {
    data: {
      value: null,
      type: Object
    },
  },
  data: {
  },
  lifetimes: {
    attached() {
      this.initEmitData()
    }
  },
  attached() {
    this.initEmitData()
  },
  behaviors: [componentBehavior],
  methods: {
    radioChange(e) {
      console.log(e)
      let dataId = this.data.data.Id
      let value = e.detail.value
      let params = {
        dataId: dataId,
        value: value
      }
      this.emitData(params);
    },
    emitData(data) {
      this.triggerEvent("radioCallBack", data);
    },
    initEmitData() {
      let data = this.data.data
      let params = null
      data.ItemList.map((item)=>{
        if(item.checked) {
          params = {
            dataId: data.Id,
            value: item.value
          }
        }
      })
      this.emitData(params);
    }
  }
})
